package simplescenegraph.math;

public class Color4f {

	public static final Color4f white = new Color4f(1, 1, 1, 1);
	
	public static final Color4f red = new Color4f(1, 0, 0, 1);
	
	public static final Color4f green = new Color4f(0, 1, 0, 1);
	
	public static final Color4f blue = new Color4f(0, 0, 1, 1);
	
	public static final Color4f black = new Color4f(0, 0, 0, 1);
	
	private float r;
	
	private float g;
	
	private float b;
	
	private float a;
	
	private float[] rgba = null;
	
	public Color4f() {
		r = 0; g = 0; b = 0; a = 0;
	}
	
	public Color4f(float r, float g, float b, float a) {
		this.r = r; this.g = g; this.b = b; this.a = a;
	}
	
	public Color4f(Color4f c0) {
		r = c0.r; g = c0.g; b = c0.b; a = c0.a;
	}
	
	public float[] toFloatArray() {
		if (rgba == null) rgba = new float[4];
		rgba[0] = r; rgba[1] = g; rgba[2] = b; rgba[3] = a;
		return rgba;
	}

	public float getRed() {
		return r;
	}

	public void setRed(float r) {
		this.r = r;
	}

	public float getGreen() {
		return g;
	}

	public void setGreen(float g) {
		this.g = g;
	}

	public float getBlue() {
		return b;
	}

	public void setBlue(float b) {
		this.b = b;
	}
	
	public float getAlpha() {
		return a;
	}	
	
	public void setAlpha(float a) {
		this.a = a;
	}
	
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		
		Color4f c0 = (Color4f) obj;
		return r == c0.r && g == c0.g && b == c0.b && a == c0.a;
	}
	
}
